package com.dyb.controller;

import org.junit.Test;
import org.unitedata.common.config.FMpcRequestConfig;
import org.unitedata.entity.ApiCommunicateResult;
import org.unitedata.entity.FMpcRequestParam;
import org.unitedata.service.impl.FMpcApiServiceImpl;

import java.util.HashMap;
import java.util.Map;


public class ApiTest {

    @Test
    public void test() {
        // sdk配置
        FMpcRequestConfig.pubKey = "EOS4trqv7piRV4jVk1bBn9Tb2mB6kgMmvgGTs4hWKR3bXzq2Jrgnb";
        FMpcRequestConfig.priKey = "5Ju1XcswZmyuxAPqmjer2LckABGXtP1cHeP3uigR5jc1v6aeBc4";
        // 超时设置，20000为20秒，默认就是20秒，可以不用设置
        FMpcRequestConfig.readTimeout = 20000;
        FMpcApiServiceImpl service = new FMpcApiServiceImpl();
        // api调用地址
        String apiUrl = "https://test-jf1-1x-n4.fudata.work/gateway/v2/api/apps/9209b4db77954f8a8594e944d988b3b9";
        // api入参
        Map data = new HashMap<>();
        data.put("id", "ad13a2a07ca4b7642959dc0c4c740ab6");
        // 调用api
        FMpcRequestParam param = new FMpcRequestParam<>();
        param.setApiUrl(apiUrl);
        param.setData(data);
        // api调用
        ApiCommunicateResult result = service.fMpcGenericInvoke(param);
        // api执行结果
        System.out.println(result);
    }
}
